# Weaviate Self Query Retriever

This example shows how to use a self query retriever with a [Weaviate](https://weaviate.io/) vector store.

If you haven't already set up Weaviate, please [follow the instructions here](/docs/integrations/vectorstores/weaviate).

## Usage

This example shows how to intialize a `SelfQueryRetriever` with a vector store:

Weaviate has their own standalone integration package with LangChain, accessible via [`@langchain/weaviate`](https://www.npmjs.com/package/@langchain/weaviate) on NPM!

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/weaviate @langchain/openai @langchain/community
```

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/retrievers/weaviate_self_query.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

You can also initialize the retriever with default search parameters that apply in
addition to the generated query:

```typescript
const selfQueryRetriever = await SelfQueryRetriever.fromLLM({
  llm,
  vectorStore,
  documentContents,
  attributeInfo,
  /**
   * We need to use a translator that translates the queries into a
   * filter format that the vector store can understand. LangChain provides one here.
   */
  structuredQueryTranslator: new WeaviateTranslator(),
  searchParams: {
    filter: {
      where: {
        operator: "Equal",
        path: ["type"],
        valueText: "movie",
      },
    },
    mergeFiltersOperator: "or",
  },
});
```

See the [official docs](https://weaviate.io/developers/weaviate/api/graphql/filters) for more on how to construct metadata filters.
